//
//  KFDNotificationParser.m
//  KFD
//
//  Created by Lucky Luke on 8/8/15.
//  Copyright (c) 2015 kfd. All rights reserved.
//

#import "KFDNotificationParser.h"
#import "NSMutableDictionary+checkForNil.h"

@implementation KFDNotificationParser

+(KFDNotification*)parseNote:(NSString *)note
{
    NSMutableDictionary* attributes=[NSMutableDictionary dictionary];
    NSArray* params=[note componentsSeparatedByString:@"&"];
    for (NSString* param in params) {
        NSArray* operands=[param componentsSeparatedByString:@"="];
        if (operands.count==2) {
            [attributes setNotNilObject:operands.lastObject forKey:operands.firstObject];
        }
    }
    KFDNotification* notification=[KFDNotification modelObjectFromDictionary:attributes];
    return notification;
}

@end
